from django.db import models
from django.contrib.auth.models import User

# Create your models here.

class Announcement(models.Model):
    """公告信息表 - 对应notice表"""
    title = models.CharField(max_length=255, blank=True, verbose_name='标题', db_comment='公告标题')
    content = models.TextField(blank=True, verbose_name='内容', db_comment='公告内容')
    time = models.DateTimeField(auto_now_add=True, null=True, blank=True, verbose_name='创建时间', db_comment='创建时间')
    user = models.ForeignKey(
        User, 
        on_delete=models.SET_NULL, 
        null=True, 
        blank=True, 
        verbose_name='创建人',
        db_comment='创建人ID'
    )
    
    class Meta:
        db_table = 'zongce_announcement'
        verbose_name = '公告信息'
        verbose_name_plural = '公告信息'
        ordering = ['-time']
        db_table_comment = '公告信息表，存储系统公告和通知'
    
    def __str__(self):
        return str(self.title) if self.title else f"公告 {self.pk}"
